package com.juyu.miliao.common.domain;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;

/**
 * @author jh
 * 2018/9/7
 */
public class AlipayConfig {

    /**
     * appid
     */
    private static String appId;

    /**
     * 应用私钥
     */
    private static String appPrivateKey;

    /**
     * 应用公钥
     */
    private static String alipayPublicKey;

    /**
     * 同步地址
     */
    private static String notifyUrl;

    public static String getAppId() {
        return appId;
    }

    @Value("${app.alipay.appId}")
    public void setAppId(String appId) {
        if (StringUtils.isEmpty(appId)) {
            throw new RuntimeException("config can not be null");
        }
        AlipayConfig.appId = appId;
    }

    public static String getAppPrivateKey() {
        return appPrivateKey;
    }

    @Value("${app.alipay.appPrivateKey}")
    public void setAppPrivateKey(String appPrivateKey) {
        if (StringUtils.isEmpty(appPrivateKey)) {
            throw new RuntimeException("config can not be null");
        }
        AlipayConfig.appPrivateKey = appPrivateKey;
    }

    public static String getAlipayPublicKey() {
        return alipayPublicKey;
    }

    @Value("${app.alipay.alipayPublicKey}")
    public void setAlipayPublicKey(String alipayPublicKey) {
        if (StringUtils.isEmpty(alipayPublicKey)) {
            throw new RuntimeException("config can not be null");
        }
        AlipayConfig.alipayPublicKey = alipayPublicKey;
    }

    public static String getNotifyUrl() {
        return notifyUrl;
    }

    @Value("${app.alipay.notifyUrl}")
    public void setNotifyUrl(String notifyUrl) {
        if (StringUtils.isEmpty(notifyUrl)) {
            throw new RuntimeException("config can not be null");
        }
        AlipayConfig.notifyUrl = notifyUrl;
    }
}
